"use strict";
/**
 * @ Author: Yoann Meclot. MSay2
 * @ Created on: 2020-09-29 11:23:15
 * @ Modified on: 2020-09-29 10:46:39
 *
 * @version 1.0
 */
/**
 * Copyright (c) 2020 MSay2, Yoann Meclot - @msay2/tspoet
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.TSProperty = void 0;
const ArrayList_js_1 = require("../utils/ArrayList.js");
const LinkedMap_js_1 = require("../utils/LinkedMap.js");
const Utils_js_1 = require("../utils/Utils.js");
const TSPoet_js_1 = require("./TSPoet.js");
/**
 * Init a new interface method or property.
 *
 * @class TSProperty
 * @version 1.0
 */
class TSProperty {
    constructor(builder) {
        this.name = Utils_js_1.Utils.checkNotNull(builder.name, "TSProperty must have a non-null name.");
        this.docs = builder.docs;
        this.parameters = builder.parameters;
        this.typeName = builder.typeName;
    }
    /**
     * Init a builder for add a interface method or property.
     *
     * @param name The name of the method or property.
     * @throws {NullPointerException} Check if the name is null.
     * @type {Builder}
     * @since 1.0
     */
    static add(name) {
        return new Builder(name);
    }
}
exports.TSProperty = TSProperty;
/**
 * @version 1.0
 */
class Builder {
    constructor(name) {
        this.parameters = new LinkedMap_js_1.LinkedMap();
        this.docs = new ArrayList_js_1.ArrayList();
        this.typeName = TSPoet_js_1.TypeName.TYPE_ANY;
        this.name = Utils_js_1.Utils.checkNotNull(name, "TSProperty must have a non-null method name.");
    }
    /**
     * Add a parameter.
     *
     * @param tsParamer The parameter to be added.
     * @throws {NullPointerException} Check if the TSParameter object is null.
     * @type {Builder}
     * @since 1.0
     */
    addParameter(name, typeName) {
        this.parameters.add(Utils_js_1.Utils.checkNotNull(name, "TSProperty must have a non-null name."), Utils_js_1.Utils.checkNotNull(typeName, "TSProperty must have a non-null TypeName object."));
        return this;
    }
    /**
     * Add a documentation.
     *
     * @param arg Your comment.
     * @throws {NullPointerException} Check if the doc is null.
     * @type {Builder}
     * @since 1.0
     */
    addDoc(arg) {
        this.docs.add(Utils_js_1.Utils.checkNotNull(arg, "TSProperty must have a non-null doc."));
        return this;
    }
    /**
     * Set a return type to method.
     *
     * @param typeName The return type.
     * @throws {NullPointerException} Check if the TypeName object is null.
     * @type {Builder}
     * @since 1.0
     */
    return(typeName) {
        this.typeName = Utils_js_1.Utils.checkNotNull(typeName, "TSProperty must have a non-null type of method.");
        return this;
    }
    /**
     * Build a property.
     *
     * @throws {NullPointerException} Check if the name is null.
     * @type {TSProperty}
     * @since 1.0
     */
    build() {
        return new TSProperty(this);
    }
}
//# sourceMappingURL=TSProperty.js.map